package com.huahai.pojo.vo.barrage;

import com.huahai.pojo.entity.Barrage;
import com.huahai.pojo.vo.user.UserVO;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.util.Date;

/**
 * 弹幕响应类
 *
 * @author huahai
 */
@Data
public class BarrageVO implements Serializable {

    private static final long serialVersionUID = -7179378916524713732L;

    /**
     * id
     */
    private Long id;

    /**
     * 弹幕内容
     */
    private String content;

    /**
     * 创建用户 id
     */
    private Long userId;

    /**
     * 创建时间
     */
    private Date createTime;

    /**
     * 更新时间
     */
    private Date updateTime;

    /**
     * 创建人信息
     */
    private UserVO user;

    /**
     * 封装类转对象
     *
     * @param barrageVO 弹幕响应封装类
     * @return 弹幕对象
     */
    public static Barrage voToObj(BarrageVO barrageVO) {
        if (barrageVO == null) {
            return null;
        }
        Barrage barrage = new Barrage();
        BeanUtils.copyProperties(barrageVO, barrage);
        return barrage;
    }

    /**
     * 对象转封装类
     *
     * @param barrage 弹幕对象
     * @return 弹幕响应封装类
     */
    public static BarrageVO objToVo(Barrage barrage) {
        if (barrage == null) {
            return null;
        }
        BarrageVO barrageVO = new BarrageVO();
        BeanUtils.copyProperties(barrage, barrageVO);
        return barrageVO;
    }
}